a tool for shared writing and social publishing
at update/reader 82 lines 2.9 kB view raw
1"use client"; 2import { useUIState } from "src/useUIState"; 3import { Footer } from "components/ActionBar/Footer"; 4import { Media } from "components/Media"; 5import { ThemePopover } from "components/ThemeManager/ThemeSetter"; 6import { Toolbar } from "components/Toolbar"; 7import { ShareOptions } from "app/[leaflet_id]/actions/ShareOptions"; 8import { HomeButton } from "app/[leaflet_id]/actions/HomeButton"; 9import { PublishButton } from "./actions/PublishButton"; 10import { useEntitySetContext } from "components/EntitySetProvider"; 11import { Watermark } from "components/Watermark"; 12import { BackToPubButton } from "./actions/BackToPubButton"; 13import { useLeafletPublicationData } from "components/PageSWRDataProvider"; 14import { useIdentityData } from "components/IdentityProvider"; 15import { useEntity } from "src/replicache"; 16import { block } from "sharp"; 17import { PostSettings } from "components/PostSettings"; 18 19export function hasBlockToolbar(blockType: string | null | undefined) { 20 return ( 21 blockType === "text" || 22 blockType === "heading" || 23 blockType === "blockquote" || 24 blockType === "button" || 25 blockType === "datetime" || 26 blockType === "image" 27 ); 28} 29export function LeafletFooter(props: { entityID: string }) { 30 let focusedBlock = useUIState((s) => s.focusedEntity); 31 32 let entity_set = useEntitySetContext(); 33 let { identity } = useIdentityData(); 34 let { data: pub } = useLeafletPublicationData(); 35 let blockType = useEntity(focusedBlock?.entityID || null, "block/type")?.data 36 .value; 37 38 return ( 39 <Media 40 mobile 41 className="mobileLeafletFooter w-full z-10 touch-none -mt-[54px] " 42 > 43 {focusedBlock && 44 focusedBlock.entityType == "block" && 45 hasBlockToolbar(blockType) && 46 entity_set.permissions.write ? ( 47 <div 48 className="w-full z-10 p-2 flex bg-bg-page pwa-padding-bottom" 49 onMouseDown={(e) => { 50 if (e.currentTarget === e.target) e.preventDefault(); 51 }} 52 > 53 <Toolbar 54 pageID={focusedBlock.parent} 55 blockID={focusedBlock.entityID} 56 blockType={blockType} 57 /> 58 </div> 59 ) : entity_set.permissions.write ? ( 60 <Footer> 61 {pub?.publications && 62 identity?.atp_did && 63 pub.publications.identity_did === identity.atp_did ? ( 64 <BackToPubButton publication={pub.publications} /> 65 ) : ( 66 <HomeButton /> 67 )} 68 <div className="mobileLeafletActions flex gap-2 shrink-0"> 69 <PublishButton entityID={props.entityID} /> 70 <ShareOptions /> 71 <PostSettings /> 72 <ThemePopover entityID={props.entityID} /> 73 </div> 74 </Footer> 75 ) : ( 76 <div className="pb-2 px-2 z-10 flex justify-end"> 77 <Watermark mobile /> 78 </div> 79 )} 80 </Media> 81 ); 82}